package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.CompetitorDao;
import cn.gson.springboot.model.mapper.CompetitorMapper;
import cn.gson.springboot.model.pojos.Competitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CompetitorService {
    @Autowired
    CompetitorMapper comMapper;
    @Autowired
    CompetitorDao comDao;

    public List<Competitor> selectCompetitor(Integer deptId,Integer filter,Integer vague,String content){
        return  comMapper.selectCompetitor(deptId,filter,vague,content);
    }


    public List<Competitor> selectCompetitorByOppId(Integer oppId){
        return comMapper.selectCompetitorByOppId(oppId);
    }

    @Transactional(transactionManager = "transactionManager")
    public void saveCompetitor(Competitor competitor){
        comDao.save(competitor);
    }

    @Transactional(transactionManager = "transactionManager")
    public void deleteCompetitor(Integer competitorId){
        comDao.deleteById(competitorId);
    }
}
